package ce.com.cenewbluesdk.entity.k2;



import java.io.Serializable;

import ce.com.cenewbluesdk.CEBC;
import ce.com.cenewbluesdk.entity.BaseData;
import ce.com.cenewbluesdk.entity.CEDevData;
import ce.com.cenewbluesdk.uitl.ByteUtil;

/**
 * Created by Administrator on 2015/11/2 0002.
 */
public class K2_SendGoal extends BaseData implements Serializable{


    private byte [] step;
    private byte [] distance;
    private byte [] calories;
    private byte [] sleep;


    public K2_SendGoal(int step, int distance, int calories, int sleep) {
        this.step = ByteUtil.intToByte(step);
        this.distance = ByteUtil.intToByte(distance);
        this.calories = ByteUtil.intToByte(calories);
        this.sleep = ByteUtil.intToByte(sleep);
    }

    public byte[] getBytes() {
        byte[] bytes = new byte[getItemSize()];

        System.arraycopy(step,0,bytes,0,4);
        System.arraycopy(distance,0,bytes,4,4);
        System.arraycopy(calories,0,bytes,8,4);
        System.arraycopy(sleep,0,bytes,12,4);

        return bytes;
    }

    public static int getItemSize() {
        return 16;
    }


    @Override
    public CEDevData toCEDevData() {
        CEDevData data=new CEDevData(CEBC.K2.CMD_TYPE_SEND,CEBC.K2.DATA_TYPE_SET_TARGET);
        data.setItemL(getItemSize());
        data.setItemNumber(1);
        data.setData(getBytes());
        return data;
    }
}
